package com.happyscan138.makefun;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.happyscan138.makefun.Urls.Urls;
import com.happyscan138.makefun.base.http;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.JsonHttpResponseHandler;
import com.loopj.android.http.RequestHandle;
import com.loopj.android.http.RequestParams;

import org.json.JSONException;
import org.json.JSONObject;

import cz.msebera.android.httpclient.Header;

import static com.loopj.android.http.AsyncHttpClient.log;

/**
 * Created by Administrator on 2017/1/7.
 */

public class Help extends AppCompatActivity implements View.OnClickListener {
    private TextView helpText;
    private ImageButton back;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.help);
        helpText=(TextView)findViewById(R.id.help_text);
        http.client=new AsyncHttpClient();
        http.params=new RequestParams();
        RequestHandle handle= http.client.post(Urls.Help, http.params,new JsonHttpResponseHandler(){
            @Override
            public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
                super.onSuccess(statusCode, headers, response);
                String jsonStr=response.toString();
                Log.e("onSuccess",jsonStr);
                try {
                    JSONObject jsonObject=new JSONObject(jsonStr);
                    JSONObject data=jsonObject.getJSONObject("data");
                    String content=data.getString("content");
                    helpText.setText(content);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });
        initView();
    }
    public void initView(){
        back=(ImageButton) findViewById(R.id.help_back);
        back.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.help_back:
                finish();
                break;
        }
    }
}
